in PHP UrlEncode () function is to convert the Chinese into a string encoding, so that does not cause the Chinese URL in the browser open garbled or error problems, let me introduce you in the use of UrlEncode () coding is some specific
In PHP Rawurlencode and Rawurlencode are the characters are encoded, the following I will introduce UrlEncode and rawurlencode the difference, there is a need to understand the friends can refer to.
The purpose of UrlEncode is to encode a string,
The principle is to convert Chinese characters into hexadecimal and string combinations according to some rules, to realize character encoding and encoding, to ensure the integrity and compatibility of characters in the process of URL data
Some time ago said that they encountered a "URL plus throw error" bug, the cause of this bug is that they use the UrlEncode function in the URL, the function will convert the space into a plus sign, which will cause the URL parsing error, and the
Project can not avoid a place to pass Chinese, the previous encounter garbled code is first in JS (coding all set on the page for the UTF-8)
JsonStr = encodeURIComponent (jsonStr ));
In the JAVA code
ProjName = URLDecoder. decode (projName, "UTF-8 ")
The login principle is still quite complicated, as I think Curl gets the page again post the idea is very simple.
Sort the functions that are encountered by the price processing string:
Copy the Code code as follows:
$encryption =
When I checked the uchome source code yesterday, I found that urlencode was used in some places, and rawurlencode was used in some places. The difference between the two methods is not very clear.CodeTo test.
Save the following code to a PHP file:
Here is a detailed explanation:///\\\
String UrlEncode (String str)
Returns a string, in addition to-_, in this string. All non-alphanumeric characters are replaced with a percent sign (%) followed by a two-digit hexadecimal number, and a space is
For URL encoding in PHP, urlencode () or rawurlencode () can be used. The difference between the two is that the former encodes space into +, while the latter encodes space into % 20, however, it should be noted that only part of the URL should be
The following is a detailed explanation :///\\\String urlencode (string str)Returns a string -_. all other non-alphanumeric characters will be replaced with a semicolon (%) followed by two hexadecimal numbers, and spaces will be encoded as the plus
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.